--
-- $Id: xpa-awk.adb,v 1.1 2006-04-14 09:46:48 bacon Exp $
--

with ada.unchecked_deallocation;
with ada.unchecked_conversion;

with ada.text_io;

package body xpa.awk is

	type awk_type is 
	record
		option: integer;
	end record;

	type awk_access is access all awk_type;

	procedure free is 
		new ada.unchecked_deallocation (awk_type, awk_access);

	function access_to_handle is 
		new ada.unchecked_conversion (awk_access, handle);
	function handle_to_access is
		new ada.unchecked_conversion (handle, awk_access);

	function open return handle is
		awk: awk_access := null;
	begin
		awk := new awk_type;
		return access_to_handle (awk);
	exception
		when others =>
			if awk /= null then 
				free (awk); 
			end if;
			raise;
	end open;

	procedure close (hnd: in handle) is
		awk: awk_access;
	begin
		awk := handle_to_access(hnd);
		free (awk);
	end close;

	procedure parse (hnd: in handle) is
		awk: awk_access;
	begin
		awk := handle_to_access(hnd);
		ada.text_io.put_line ("ada.parse");
		
	end parse;

	procedure run (hnd: in handle) is
		awk: awk_access;
	begin
		awk := handle_to_access(hnd);
	end run;

end xpa.awk;
